#import "ephemeraAppDelegate.h"
#import "mapViewController.h"
#import "ephemeraViewController.h"
#import "timelineViewController.h"

@implementation ephemeraAppDelegate


@synthesize window, navCtrl, eDict,latDict, longDict, blurbDict, iDict;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    

	
    // Override point for customization after app launch    
	[self loadEphemera];
//	[navCtrl view].latDict = latDict;
    [window addSubview:[navCtrl view]];
    [window makeKeyAndVisible];

	return YES;
}

- (IBAction)viewTimeline{
	NSLog(@"here");
	timelineViewController *timelineVC = [[timelineViewController alloc] initWithNibName:@"timelineViewController" bundle:nil];
	timelineVC.yearDict = yearDict;
	timelineVC.iDict = iDict;
	timelineVC.blurbDict = blurbDict;
	[navCtrl pushViewController:timelineVC animated: YES];
	[timelineVC release];

}

-(void)loadEphemera{
	NSString *myPath = [[NSBundle mainBundle] pathForResource:@"ephemera_source" ofType:@"xml"];		
	eDict = [[NSDictionary alloc] initWithContentsOfFile:myPath];

	myPath = [[NSBundle mainBundle] pathForResource:@"ephemera_source_img" ofType:@"xml"];		
	iDict = [[NSDictionary alloc] initWithContentsOfFile:myPath];
	
	myPath = [[NSBundle mainBundle] pathForResource:@"ephemera_source_long" ofType:@"xml"];		
	longDict = [[NSDictionary alloc] initWithContentsOfFile:myPath];

	myPath = [[NSBundle mainBundle] pathForResource:@"ephemera_source_lat" ofType:@"xml"];		
	latDict = [[NSDictionary alloc] initWithContentsOfFile:myPath];


	myPath = [[NSBundle mainBundle] pathForResource:@"ephemera_source_blurb" ofType:@"xml"];		
	blurbDict = [[NSDictionary alloc] initWithContentsOfFile:myPath];

	myPath = [[NSBundle mainBundle] pathForResource:@"ephemera_year" ofType:@"xml"];		
	yearDict = [[NSDictionary alloc] initWithContentsOfFile:myPath];

}

- (void)applicationWillTerminate:(UIApplication *)application {
	
   }



- (IBAction)viewEphemera{
	ephemeraViewController *ephemeraVC = [[ephemeraViewController alloc] initWithNibName:@"ephemeraViewController" bundle:nil];
	ephemeraVC.iDict = iDict;
	ephemeraVC.eDict = eDict;
//	ephemeraVC.longDict = longDict;
//	ephemeraVC.latDict = latDict;
	
	[navCtrl pushViewController:ephemeraVC animated: YES];
	[ephemeraVC release];
	
}


#pragma mark -
#pragma mark Core Data stack



- (void)dealloc {
	[navCtrl release];
    [window release];
	[eDict release];
    [super dealloc];
}


@end
